package com.ruoyi.ldzlsc.service.Impl;

import com.ruoyi.ldzlsc.domain.vo.ScTaskVo;
import com.ruoyi.ldzlsc.mapper.ScTaskMapper;
import com.ruoyi.ldzlsc.service.IScTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ScTaskServiceImpl implements IScTaskService {

    @Autowired
    private ScTaskMapper scTaskMapper;

    @Override
    public List<ScTaskVo> selectScTaskList(ScTaskVo scTaskVo) {
        List<ScTaskVo> list = scTaskMapper.selectScTaskList(scTaskVo);
        for (ScTaskVo task : list) {
            if (task.getPlanStartTime() != null && task.getPlanEndTime() != null) {
                long diff = task.getPlanEndTime().getTime() - task.getPlanStartTime().getTime();
                long hours = diff / (60 * 60 * 1000);
                long minutes = (diff / (60 * 1000)) % 60;
                task.setPlannedDuration(hours + "小时" + minutes + "分钟");
            }
        }
        return list;
    }
} 